<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>不用函数柯里化</title>
    <style>
        .container{
            display: flex;
            align-items: center;
            justify-content: space-around;
            height: 100px;
            margin: 0 auto;
            margin-top: 300px;
            width: 50%;
            border-radius: 30px;
            border: 1px #333 solid;
        }
    </style>
</head>
<body>
    <!-- 引入React核心库 -->
    <script src="../JS/react.development.js"></script>
    <!-- 引入ReactDOM，用于支持react操作DOM -->
    <script src="../JS/react-dom.development.js"></script>
    <!-- 引入babel 用于将书写的JSX语法 编译成JS语法 -->
    <script src="../JS/babel.min.js"></script>

    <div id="test"></div>
    <script type="text/babel">
        class Demo extends React.Component{
            state={
                username:'',
                password:''
            }
            showData = (e)=>{
                e.preventDefault()
                const {username,password} = this.state
                alert(`用户名:${username},密码:${password}`)
            }
            saveData = (type,e) =>{
                this.setState({[type]:e.target.value})
            }
            render(){
                return(
                    <form onSubmit={this.showData} className="container">
                       用户名: <input type="text" onChange={e=>this.saveData('username',e)}  placeholder="请输入用户名" name="username"/> {/* */}
                       密码: <input type="password" onChange={e=>this.saveData('password',e)} placeholder="请输入密码" name="password" />
                       <button onClick={this.showData}>显示输入数据</button>
                    </form>
                )
            }
        }
        ReactDOM.render(<Demo/>,document.getElementById('test'))
    </script>

    <!-- 
        总结陈词
           
     -->

</body>
</html>